home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Documentation / Books / Learn Java on the Macintosh / Learn Java Projects / 09.01 - employee 1 / Employee1.java < prev    next >
Text File  |  1996-04-22  |  829b  |  34 lines

  1. /* -------------------------------------------------------------
  2. This applet illustrates using instance variables and instance
  3. methods.
  4.  
  5. Java's classes: Applet    (applet)
  6.                 System    (lang)
  7.  
  8. Custom classes: Employee1
  9.  
  10. ------------------------------------------------------------- */
  11. public class Employee1 extends java.applet.Applet {
  12.  
  13.    int hourlyWage;
  14.    int hoursWorked;
  15.    
  16.    int earnedIncome() {
  17.       return hourlyWage * hoursWorked;
  18.    }
  19.    
  20.    public void init() {
  21.       hourlyWage = 10;
  22.       hoursWorked = 20;
  23.    }
  24.    
  25.    public void start() {
  26.       int earnedIncome;
  27.       
  28.       System.out.println("hourly wage = " + hourlyWage);
  29.       System.out.println("hours worked = " + hoursWorked);
  30.       
  31.       earnedIncome = earnedIncome();
  32.       System.out.println("earned income = " + earnedIncome);
  33.    }
  34. }